'use strict';

const Controller = require('./base');

class PermissionController extends Controller {

  // 列表
  async find() {
    const { ctx, service } = this;
    console.log(ctx.query)
    const page = ctx.query.pageNo;
    const pageSize = 10;
    const data = await service.permission.find(page, pageSize);
    this.success(data);
  }

  // 无分页列表
  async list() {
    const { service } = this;
    const data = await service.permission.list();
    this.success(data);
  }

  // 新增
  async create() {
    const { ctx, service } = this;
    console.log({ ...ctx.request.body })
    const result = await service.permission.create({ ...ctx.request.body });
    this.success();
  }

  // 删除
  async delete() {
    const { ctx, service } = this;
    const id = ctx.query.id;
    const result = await service.permission.delete(id);
    this.success(result);
  }
}

module.exports = PermissionController;
